/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Revised2011CreateXMLWindow.java
 *
 * Created on Mar 25, 2011, 11:42:39 AM
 */

package org.dlsu.pdfgen.gui;

import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.DefaultListModel;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;
import java.io.*;

/**
 * 
 * @author Alvin
 */
public class Revised2011CreateXMLWindow extends javax.swing.JDialog {

	/** Creates new form Revised2011CreateXMLWindow */
	public Revised2011CreateXMLWindow(java.awt.Frame parent, boolean modal) {
		super(parent, modal);
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				int confirm = JOptionPane.showConfirmDialog(null,
						"Are you sure you want to exit?", "User Confirmation",
						JOptionPane.YES_NO_OPTION);
				if (confirm == JOptionPane.YES_OPTION){
					setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
				}
				else{
					setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
				}
			}
		});
		initComponents();
		Dimension dim = getToolkit().getScreenSize();
		Rectangle abounds = getBounds();
		setLocation((dim.width - abounds.width) / 2,
				(dim.height - abounds.height) / 2);
		System.out.println("GUI started.");
		setVisible(true);
		setLocationRelativeTo(null);
	}

	private void initComponents() {

		createXMLLabel = new javax.swing.JLabel();
		XMLTabbedPane = new javax.swing.JTabbedPane();
		detailsPanel = new javax.swing.JPanel();
		termLabel = new javax.swing.JLabel();
		facultyLabel = new javax.swing.JLabel();
		roomLabel = new javax.swing.JLabel();
		timeLabel = new javax.swing.JLabel();
		courseCodeLabel = new javax.swing.JLabel();
		collegeLabel = new javax.swing.JLabel();
		departmentLabel = new javax.swing.JLabel();
		collegeTxtField = new javax.swing.JTextField();
		departmentTxtField = new javax.swing.JTextField();
		courseCodeTxtField = new javax.swing.JTextField();
		facultyTxtField = new javax.swing.JTextField();
		termTxtField = new javax.swing.JTextField();
		timeTxtField = new javax.swing.JTextField();
		roomTxtField = new javax.swing.JTextField();
		descriptionPanel = new javax.swing.JPanel();
		descriptionScrollPane = new javax.swing.JScrollPane();
		descriptionTxtArea = new javax.swing.JTextArea();
		learningOutcomesPanel = new javax.swing.JPanel();
		learningOutcomesPreamblePanel = new javax.swing.JPanel();
		learningObjectivePreambleScrollPane = new javax.swing.JScrollPane();
		learningObjectivePreambleTxtArea = new javax.swing.JTextArea();
		learningOutcomesListPanel = new javax.swing.JPanel();
		learningOutcomesListScrollPane = new javax.swing.JScrollPane();
		learningOutcomeListModel = new DefaultListModel();
		learningOutcomesList = new javax.swing.JList(learningOutcomeListModel);
		learningOutcomeRemoveButton = new javax.swing.JButton();
		learningOutcomeAddButton = new javax.swing.JButton();
		learningOutcomeTxtField = new javax.swing.JTextField();
		learningPlanPanel = new javax.swing.JPanel();
		topicsTableScrollPane = new javax.swing.JScrollPane();
		topicTableModel = new DefaultTableModel();
		topicsTable = new javax.swing.JTable();
		topicsTable.setModel(topicTableModel);
		topicLearningOutcomeLabel = new javax.swing.JLabel();
		topicLabel = new javax.swing.JLabel();
		topicWeekLabel = new javax.swing.JLabel();
		topicLearningActivitiesLabel = new javax.swing.JLabel();
		topicWeekTxtField = new javax.swing.JTextField();
		topicLearningOutcomeTxtField = new javax.swing.JTextField();
		topicTxtField = new javax.swing.JTextField();
		topicLearningActivitiesTxtField = new javax.swing.JTextField();
		topicAddButton = new javax.swing.JButton();
		topicRemoveButton = new javax.swing.JButton();
		requirementsPanel = new javax.swing.JPanel();
		requirementListScrollPane = new javax.swing.JScrollPane();
		requirementListModel = new DefaultListModel();
		requirementsList = new javax.swing.JList(requirementListModel);
		requirementRemoveButton = new javax.swing.JButton();
		requirementAddButton = new javax.swing.JButton();
		requirementTxtField = new javax.swing.JTextField();
		requirementListTypeLabel = new javax.swing.JLabel();
		RequirmentListTypeComboBox = new javax.swing.JComboBox();
		assessmentPanel = new javax.swing.JPanel();
		assessmentTableScrollPane = new javax.swing.JScrollPane();
		assessmentTableModel = new DefaultTableModel();
		assessmentTable = new javax.swing.JTable(assessmentTableModel);
		itemLabel = new javax.swing.JLabel();
		valueLabel = new javax.swing.JLabel();
		assessmentItemTxtField = new javax.swing.JTextField();
		assessmentValueTxtField = new javax.swing.JTextField();
		assessmentRemoveButton = new javax.swing.JButton();
		assessmentAddButton = new javax.swing.JButton();
		textMaterialsPanel = new javax.swing.JPanel();
		textMaterialComboBox = new javax.swing.JComboBox();
		textMaterialListTypeLabel = new javax.swing.JLabel();
		textMaterialTxtField = new javax.swing.JTextField();
		textMaterialListScrollPane = new javax.swing.JScrollPane();
		textMaterialListModel = new DefaultListModel();
		textMaterialsList = new javax.swing.JList(textMaterialListModel);
		textMaterialRemoveButton = new javax.swing.JButton();
		textMaterialAddButton = new javax.swing.JButton();
		referencesPanel = new javax.swing.JPanel();
		referenceTxtField = new javax.swing.JTextField();
		referenceScrollPane = new javax.swing.JScrollPane();
		referenceListModel = new DefaultListModel();
		referencesList = new javax.swing.JList(referenceListModel);
		referenceRemoveButton = new javax.swing.JButton();
		referenceAddButton = new javax.swing.JButton();
		clearButton = new javax.swing.JButton();
		saveButton = new javax.swing.JButton();

		setTitle("Create XML");
		setResizable(false);

		createXMLLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
		createXMLLabel.setText("Create XML");

		termLabel.setText("Term");

		facultyLabel.setText("Faculty");

		roomLabel.setText("Room");

		timeLabel.setText("Class Days and Time");

		courseCodeLabel.setText("Course Code");

		collegeLabel.setText("College");

		departmentLabel.setText("Department");

		collegeTxtField.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				collegeTxtFieldActionPerformed(evt);
			}
		});

		departmentTxtField
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						departmentTxtFieldActionPerformed(evt);
					}
				});

		courseCodeTxtField
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						courseCodeTxtFieldActionPerformed(evt);
					}
				});

		facultyTxtField.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				facultyTxtFieldActionPerformed(evt);
			}
		});

		termTxtField.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				termTxtFieldActionPerformed(evt);
			}
		});

		timeTxtField.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				timeTxtFieldActionPerformed(evt);
			}
		});

		roomTxtField.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				roomTxtFieldActionPerformed(evt);
			}
		});

		clearButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if (JOptionPane.showConfirmDialog(null,
						"Data may be lost! Confirm?", "Clear",
						JOptionPane.YES_NO_OPTION) == 0) {
					dispose();
					new Revised2011CreateXMLWindow(parent, modal);
				}
			}
		});

		learningOutcomeAddButton
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						String txtField = learningOutcomeTxtField.getText();
						if (!txtField.split("\\s+")[0].equals("")) {
							learningOutcomeListModel.addElement(txtField);
						}
						learningOutcomeTxtField.setText("");
					}
				});

		learningOutcomeRemoveButton
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(ActionEvent arg0) {

						for (int i = learningOutcomesList.getModel().getSize() - 1; i >= 0; i--)
							if (learningOutcomesList.isSelectedIndex(i))
								learningOutcomeListModel.remove(i);
					}
				});

		requirementAddButton
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(ActionEvent e) {
						requirementListModel.addElement(requirementTxtField
								.getText());
						requirementTxtField.setText("");
					}
				});

		requirementRemoveButton
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(ActionEvent e) {
						if (requirementsList.getSelectedIndex() != -1) {
							for (int i = requirementsList.getModel().getSize() - 1; i >= 0; i--)
								if (requirementsList.isSelectedIndex(i))
									requirementListModel.remove(i);
						} else {
							JOptionPane.showMessageDialog(null,
									"Select a row you want to delete.",
									"Cannot delete",
									JOptionPane.WARNING_MESSAGE);
						}
					}
				});

		referenceAddButton
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						referenceListModel.addElement(referenceTxtField
								.getText());
						referenceTxtField.setText("");
					}
				});

		referenceRemoveButton
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(ActionEvent arg0) {

						for (int i = referencesList.getModel().getSize() - 1; i >= 0; i--)
							if (referencesList.isSelectedIndex(i))
								referenceListModel.remove(i);
					}
				});

		textMaterialAddButton
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						textMaterialListModel.addElement(textMaterialTxtField
								.getText());
						textMaterialTxtField.setText("");
					}
				});

		textMaterialRemoveButton
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(ActionEvent arg0) {

						for (int i = textMaterialsList.getModel().getSize() - 1; i >= 0; i--)
							if (textMaterialsList.isSelectedIndex(i))
								textMaterialListModel.remove(i);
					}
				});

		topicAddButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if (!topicLearningOutcomeTxtField.getText().equals("")
						&& !topicTxtField.getText().equals("")
						&& !topicWeekTxtField.getText().equals("")
						&& !topicLearningActivitiesTxtField.getText()
								.equals("")) {
					((DefaultTableModel) topicsTable.getModel())
							.addRow(new Object[] {
									topicLearningOutcomeTxtField.getText(),
									topicTxtField.getText(),
									topicWeekTxtField.getText(),
									topicLearningActivitiesTxtField.getText() });
					topicLearningOutcomeTxtField.setText("");
					topicTxtField.setText("");
					topicWeekTxtField.setText("");
					topicLearningActivitiesTxtField.setText("");
				} else {
					JOptionPane.showMessageDialog(null,
							"Please don't leave any field blank!");
				}
			}
		});

		topicRemoveButton
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						if (topicsTable.getSelectedRow() != -1)
							((DefaultTableModel) topicsTable.getModel())
									.removeRow(topicsTable.getSelectedRow());
					}
				});

		assessmentAddButton
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						if (!assessmentItemTxtField.getText().trim().equals("")
								&& !assessmentValueTxtField.getText().trim()
										.equals("")) {
							((DefaultTableModel) assessmentTable.getModel())
									.addRow(new Object[] {
											assessmentItemTxtField.getText(),
											assessmentValueTxtField.getText() });
							assessmentItemTxtField.setText("");
							assessmentValueTxtField.setText("");
						}
					}
				});

		assessmentRemoveButton
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						if (assessmentTable.getSelectedRow() != -1) {
							DefaultTableModel model = (DefaultTableModel) assessmentTable
									.getModel();
							model.removeRow(assessmentTable.getSelectedRow());
						} else {
							JOptionPane.showMessageDialog(null,
									"Select a row you want to delete.",
									"Cannot delete",
									JOptionPane.WARNING_MESSAGE);
						}
					}
				});

		// //////////////
		saveButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				saveButtonActionPerformed(arg0);
			}
		});
		// //////////////
		javax.swing.GroupLayout detailsPanelLayout = new javax.swing.GroupLayout(
				detailsPanel);
		detailsPanel.setLayout(detailsPanelLayout);
		detailsPanelLayout
				.setHorizontalGroup(detailsPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								detailsPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												detailsPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(
																courseCodeLabel)
														.addComponent(
																facultyLabel)
														.addComponent(termLabel)
														.addComponent(timeLabel)
														.addComponent(roomLabel)
														.addComponent(
																collegeLabel)
														.addComponent(
																departmentLabel))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												detailsPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																collegeTxtField,
																javax.swing.GroupLayout.Alignment.TRAILING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																317,
																Short.MAX_VALUE)
														.addComponent(
																departmentTxtField,
																javax.swing.GroupLayout.Alignment.TRAILING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																317,
																Short.MAX_VALUE)
														.addComponent(
																courseCodeTxtField,
																javax.swing.GroupLayout.Alignment.TRAILING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																317,
																Short.MAX_VALUE)
														.addComponent(
																facultyTxtField,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																317,
																Short.MAX_VALUE)
														.addGroup(
																detailsPanelLayout
																		.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.TRAILING,
																				false)
																		.addComponent(
																				roomTxtField,
																				javax.swing.GroupLayout.Alignment.LEADING)
																		.addComponent(
																				timeTxtField,
																				javax.swing.GroupLayout.Alignment.LEADING)
																		.addComponent(
																				termTxtField,
																				javax.swing.GroupLayout.Alignment.LEADING,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				143,
																				javax.swing.GroupLayout.PREFERRED_SIZE)))
										.addContainerGap()));
		detailsPanelLayout
				.setVerticalGroup(detailsPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								detailsPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												detailsPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																collegeLabel)
														.addComponent(
																collegeTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												detailsPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																departmentLabel)
														.addComponent(
																departmentTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												detailsPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																courseCodeLabel)
														.addComponent(
																courseCodeTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												detailsPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																facultyLabel)
														.addComponent(
																facultyTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												detailsPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(termLabel)
														.addComponent(
																termTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												detailsPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(timeLabel)
														.addComponent(
																timeTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												detailsPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(roomLabel)
														.addComponent(
																roomTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addContainerGap(88, Short.MAX_VALUE)));

		XMLTabbedPane.addTab("Details", detailsPanel);

		descriptionTxtArea.setColumns(20);
		descriptionTxtArea.setFont(new java.awt.Font("Tahoma", 0, 11));
		descriptionTxtArea.setRows(5);
		descriptionTxtArea.setCursor(new java.awt.Cursor(
				java.awt.Cursor.TEXT_CURSOR));
		descriptionScrollPane.setViewportView(descriptionTxtArea);

		javax.swing.GroupLayout descriptionPanelLayout = new javax.swing.GroupLayout(
				descriptionPanel);
		descriptionPanel.setLayout(descriptionPanelLayout);
		descriptionPanelLayout.setHorizontalGroup(descriptionPanelLayout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				descriptionPanelLayout
						.createSequentialGroup()
						.addContainerGap()
						.addComponent(descriptionScrollPane,
								javax.swing.GroupLayout.DEFAULT_SIZE, 419,
								Short.MAX_VALUE).addContainerGap()));
		descriptionPanelLayout.setVerticalGroup(descriptionPanelLayout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				descriptionPanelLayout
						.createSequentialGroup()
						.addContainerGap()
						.addComponent(descriptionScrollPane,
								javax.swing.GroupLayout.DEFAULT_SIZE, 279,
								Short.MAX_VALUE).addContainerGap()));

		XMLTabbedPane.addTab("Description", descriptionPanel);

		learningOutcomesPreamblePanel.setBorder(javax.swing.BorderFactory
				.createTitledBorder("Preamble"));

		learningObjectivePreambleTxtArea.setColumns(20);
		learningObjectivePreambleTxtArea.setFont(new java.awt.Font("Tahoma", 0,
				11));
		learningObjectivePreambleTxtArea.setRows(3);
		learningObjectivePreambleScrollPane.setViewportView(learningObjectivePreambleTxtArea);

		javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(
				learningOutcomesPreamblePanel);
		learningOutcomesPreamblePanel.setLayout(jPanel9Layout);
		jPanel9Layout.setHorizontalGroup(jPanel9Layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				jPanel9Layout
						.createSequentialGroup()
						.addContainerGap()
						.addComponent(learningObjectivePreambleScrollPane,
								javax.swing.GroupLayout.DEFAULT_SIZE, 387,
								Short.MAX_VALUE).addContainerGap()));
		jPanel9Layout.setVerticalGroup(jPanel9Layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				jPanel9Layout
						.createSequentialGroup()
						.addContainerGap()
						.addComponent(learningObjectivePreambleScrollPane,
								javax.swing.GroupLayout.PREFERRED_SIZE, 69,
								javax.swing.GroupLayout.PREFERRED_SIZE)
						.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE)));

		learningOutcomesListPanel.setBorder(javax.swing.BorderFactory
				.createTitledBorder("Learning Outcomes"));

		learningOutcomesListScrollPane.setViewportView(learningOutcomesList);

		learningOutcomeRemoveButton.setText("Remove");

		learningOutcomeAddButton.setText("Add");

		javax.swing.GroupLayout learningOutcomesListPanelLayout = new javax.swing.GroupLayout(
				learningOutcomesListPanel);
		learningOutcomesListPanel.setLayout(learningOutcomesListPanelLayout);
		learningOutcomesListPanelLayout
				.setHorizontalGroup(learningOutcomesListPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								learningOutcomesListPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												learningOutcomesListPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(
																learningOutcomesListScrollPane,
																javax.swing.GroupLayout.Alignment.LEADING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																387,
																Short.MAX_VALUE)
														.addGroup(
																learningOutcomesListPanelLayout
																		.createSequentialGroup()
																		.addComponent(
																				learningOutcomeTxtField,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				253,
																				Short.MAX_VALUE)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				learningOutcomeAddButton)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				learningOutcomeRemoveButton)))
										.addContainerGap()));
		learningOutcomesListPanelLayout
				.setVerticalGroup(learningOutcomesListPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								learningOutcomesListPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												learningOutcomesListScrollPane,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												77, Short.MAX_VALUE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												learningOutcomesListPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																learningOutcomeRemoveButton)
														.addComponent(
																learningOutcomeAddButton)
														.addComponent(
																learningOutcomeTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addContainerGap()));

		javax.swing.GroupLayout learningOutcomesPanelLayout = new javax.swing.GroupLayout(
				learningOutcomesPanel);
		learningOutcomesPanel.setLayout(learningOutcomesPanelLayout);
		learningOutcomesPanelLayout
				.setHorizontalGroup(learningOutcomesPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								learningOutcomesPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												learningOutcomesPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(
																learningOutcomesListPanel,
																javax.swing.GroupLayout.Alignment.LEADING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																learningOutcomesPreamblePanel,
																javax.swing.GroupLayout.Alignment.LEADING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.addContainerGap()));
		learningOutcomesPanelLayout
				.setVerticalGroup(learningOutcomesPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								learningOutcomesPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												learningOutcomesPreamblePanel,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												learningOutcomesListPanel,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addContainerGap()));

		XMLTabbedPane.addTab("Learning Outcomes", learningOutcomesPanel);

		topicsTable.setModel(new javax.swing.table.DefaultTableModel(
				new Object[][] {

				}, new String[] { "Learning Outcome", "Topic", "Week",
						"Learning Activities" }) {
			boolean[] canEdit = new boolean[] { false, false, false, false };

			public boolean isCellEditable(int rowIndex, int columnIndex) {
				return canEdit[columnIndex];
			}
		});
		topicsTableScrollPane.setViewportView(topicsTable);

		topicLearningOutcomeLabel.setText("Learning Outcome");

		topicLabel.setText("Topic");

		topicWeekLabel.setText("Week No.");

		topicLearningActivitiesLabel.setText("Learning Activities");

		topicAddButton.setText("Add");
		topicAddButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				topicAddButtonActionPerformed(evt);
			}
		});

		topicRemoveButton.setText("Remove");
		topicRemoveButton
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						topicRemoveButtonActionPerformed(evt);
					}
				});

		javax.swing.GroupLayout learningPlanPanelLayout = new javax.swing.GroupLayout(
				learningPlanPanel);
		learningPlanPanel.setLayout(learningPlanPanelLayout);
		learningPlanPanelLayout
				.setHorizontalGroup(learningPlanPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								learningPlanPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												learningPlanPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(
																topicsTableScrollPane,
																javax.swing.GroupLayout.Alignment.LEADING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																419,
																Short.MAX_VALUE)
														.addGroup(
																javax.swing.GroupLayout.Alignment.LEADING,
																learningPlanPanelLayout
																		.createSequentialGroup()
																		.addGroup(
																				learningPlanPanelLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.TRAILING)
																						.addComponent(
																								topicLearningOutcomeLabel)
																						.addComponent(
																								topicLabel)
																						.addComponent(
																								topicWeekLabel)
																						.addComponent(
																								topicLearningActivitiesLabel))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
																		.addGroup(
																				learningPlanPanelLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								topicLearningOutcomeTxtField,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								381,
																								Short.MAX_VALUE)
																						.addComponent(
																								topicTxtField,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								381,
																								Short.MAX_VALUE)
																						.addComponent(
																								topicWeekTxtField,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								381,
																								Short.MAX_VALUE)
																						.addComponent(
																								topicLearningActivitiesTxtField,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								381,
																								Short.MAX_VALUE)))
														.addGroup(
																learningPlanPanelLayout
																		.createSequentialGroup()
																		.addComponent(
																				topicAddButton)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				topicRemoveButton)))
										.addContainerGap()));
		learningPlanPanelLayout
				.setVerticalGroup(learningPlanPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								learningPlanPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												topicsTableScrollPane,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												172, Short.MAX_VALUE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												learningPlanPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																topicLearningOutcomeLabel)
														.addComponent(
																topicLearningOutcomeTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												learningPlanPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																topicLabel)
														.addComponent(
																topicTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												learningPlanPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																topicWeekLabel)
														.addComponent(
																topicWeekTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												learningPlanPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																topicLearningActivitiesLabel)
														.addComponent(
																topicLearningActivitiesTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												learningPlanPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																topicRemoveButton)
														.addComponent(
																topicAddButton))
										.addContainerGap()));

		XMLTabbedPane.addTab("Learning Plan", learningPlanPanel);

		requirementListScrollPane.setViewportView(requirementsList);

		requirementRemoveButton.setText("Remove");
		requirementRemoveButton
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						requirementRemoveButtonActionPerformed(evt);
					}
				});

		requirementAddButton.setText("Add");

		requirementListTypeLabel.setText("List Type");

		RequirmentListTypeComboBox
				.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
						"Numbered", "Bulleted" }));

		javax.swing.GroupLayout requirementsPanelLayout = new javax.swing.GroupLayout(
				requirementsPanel);
		requirementsPanel.setLayout(requirementsPanelLayout);
		requirementsPanelLayout
				.setHorizontalGroup(requirementsPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								requirementsPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												requirementsPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(
																requirementListScrollPane,
																javax.swing.GroupLayout.Alignment.LEADING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																419,
																Short.MAX_VALUE)
														.addGroup(
																requirementsPanelLayout
																		.createSequentialGroup()
																		.addComponent(
																				requirementTxtField,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				285,
																				Short.MAX_VALUE)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				requirementAddButton)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				requirementRemoveButton))
														.addGroup(
																javax.swing.GroupLayout.Alignment.LEADING,
																requirementsPanelLayout
																		.createSequentialGroup()
																		.addComponent(
																				requirementListTypeLabel)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				RequirmentListTypeComboBox,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				109,
																				javax.swing.GroupLayout.PREFERRED_SIZE)))
										.addContainerGap()));
		requirementsPanelLayout
				.setVerticalGroup(requirementsPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								requirementsPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												requirementsPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																requirementListTypeLabel)
														.addComponent(
																RequirmentListTypeComboBox,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												requirementListScrollPane,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												224, Short.MAX_VALUE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												requirementsPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																requirementRemoveButton)
														.addComponent(
																requirementAddButton)
														.addComponent(
																requirementTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addContainerGap()));

		XMLTabbedPane.addTab("Requirements", requirementsPanel);

		assessmentTable.setModel(new javax.swing.table.DefaultTableModel(
				new Object[][] {

				}, new String[] { "Item", "Value" }) {
			boolean[] canEdit = new boolean[] { false, false };

			public boolean isCellEditable(int rowIndex, int columnIndex) {
				return canEdit[columnIndex];
			}
		});
		assessmentTableScrollPane.setViewportView(assessmentTable);

		itemLabel.setText("Item");

		valueLabel.setText("Value");

		assessmentItemTxtField
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						assessmentItemTxtFieldActionPerformed(evt);
					}
				});

		assessmentRemoveButton.setText("Remove");

		assessmentAddButton.setText("Add");

		javax.swing.GroupLayout assessmentPanelLayout = new javax.swing.GroupLayout(
				assessmentPanel);
		assessmentPanel.setLayout(assessmentPanelLayout);
		assessmentPanelLayout
				.setHorizontalGroup(assessmentPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								assessmentPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												assessmentPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(
																assessmentTableScrollPane,
																javax.swing.GroupLayout.Alignment.LEADING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																419,
																Short.MAX_VALUE)
														.addGroup(
																javax.swing.GroupLayout.Alignment.LEADING,
																assessmentPanelLayout
																		.createSequentialGroup()
																		.addGroup(
																				assessmentPanelLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.TRAILING)
																						.addComponent(
																								itemLabel)
																						.addComponent(
																								valueLabel))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
																		.addGroup(
																				assessmentPanelLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								assessmentValueTxtField,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								383,
																								Short.MAX_VALUE)
																						.addComponent(
																								assessmentItemTxtField,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								383,
																								Short.MAX_VALUE)))
														.addGroup(
																assessmentPanelLayout
																		.createSequentialGroup()
																		.addComponent(
																				assessmentAddButton)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				assessmentRemoveButton)))
										.addContainerGap()));
		assessmentPanelLayout
				.setVerticalGroup(assessmentPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								assessmentPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												assessmentTableScrollPane,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												198, Short.MAX_VALUE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												assessmentPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(itemLabel)
														.addComponent(
																assessmentItemTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												assessmentPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																assessmentValueTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE)
														.addComponent(
																valueLabel))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												assessmentPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																assessmentRemoveButton)
														.addComponent(
																assessmentAddButton))
										.addContainerGap()));

		XMLTabbedPane.addTab("Assessment", assessmentPanel);

		textMaterialComboBox.setModel(new javax.swing.DefaultComboBoxModel(
				new String[] { "Numbered", "Bulleted" }));

		textMaterialListTypeLabel.setText("List Type");

		textMaterialListScrollPane.setViewportView(textMaterialsList);

		textMaterialRemoveButton.setText("Remove");
		textMaterialRemoveButton
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						jButton9ActionPerformed(evt);
					}
				});

		textMaterialAddButton.setText("Add");

		javax.swing.GroupLayout textMaterialsPanelLayout = new javax.swing.GroupLayout(
				textMaterialsPanel);
		textMaterialsPanel.setLayout(textMaterialsPanelLayout);
		textMaterialsPanelLayout
				.setHorizontalGroup(textMaterialsPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								textMaterialsPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												textMaterialsPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(
																textMaterialListScrollPane,
																javax.swing.GroupLayout.Alignment.LEADING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																419,
																Short.MAX_VALUE)
														.addGroup(
																textMaterialsPanelLayout
																		.createSequentialGroup()
																		.addComponent(
																				textMaterialTxtField,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				285,
																				Short.MAX_VALUE)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				textMaterialAddButton)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				textMaterialRemoveButton))
														.addGroup(
																javax.swing.GroupLayout.Alignment.LEADING,
																textMaterialsPanelLayout
																		.createSequentialGroup()
																		.addComponent(
																				textMaterialListTypeLabel)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				textMaterialComboBox,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				109,
																				javax.swing.GroupLayout.PREFERRED_SIZE)))
										.addContainerGap()));
		textMaterialsPanelLayout
				.setVerticalGroup(textMaterialsPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								textMaterialsPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												textMaterialsPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																textMaterialListTypeLabel)
														.addComponent(
																textMaterialComboBox,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												textMaterialListScrollPane,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												224, Short.MAX_VALUE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												textMaterialsPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																textMaterialRemoveButton)
														.addComponent(
																textMaterialAddButton)
														.addComponent(
																textMaterialTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addContainerGap()));

		XMLTabbedPane.addTab("Text/Materials", textMaterialsPanel);

		referenceScrollPane.setViewportView(referencesList);

		referenceRemoveButton.setText("Remove");
		referenceRemoveButton
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						jButton11ActionPerformed(evt);
					}
				});

		referenceAddButton.setText("Add");

		javax.swing.GroupLayout referencesPanelLayout = new javax.swing.GroupLayout(
				referencesPanel);
		referencesPanel.setLayout(referencesPanelLayout);
		referencesPanelLayout
				.setHorizontalGroup(referencesPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGap(0, 439, Short.MAX_VALUE)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								referencesPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												referencesPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(
																referenceScrollPane,
																javax.swing.GroupLayout.Alignment.LEADING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																419,
																Short.MAX_VALUE)
														.addGroup(
																referencesPanelLayout
																		.createSequentialGroup()
																		.addComponent(
																				referenceTxtField,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				285,
																				Short.MAX_VALUE)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				referenceAddButton)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				referenceRemoveButton)))
										.addContainerGap()));
		referencesPanelLayout
				.setVerticalGroup(referencesPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								referencesPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												referenceScrollPane,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												250, Short.MAX_VALUE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												referencesPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																referenceRemoveButton)
														.addComponent(
																referenceAddButton)
														.addComponent(
																referenceTxtField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addContainerGap()));

		XMLTabbedPane.addTab("References", referencesPanel);

		clearButton.setText("Clear");

		saveButton.setText("Save");

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup().addContainerGap()
								.addComponent(createXMLLabel)
								.addContainerGap(354, Short.MAX_VALUE))
				.addGroup(
						javax.swing.GroupLayout.Alignment.TRAILING,
						layout.createSequentialGroup()
								.addContainerGap()
								.addComponent(clearButton)
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.RELATED,
										245, Short.MAX_VALUE)
								.addComponent(saveButton).addContainerGap())
				.addComponent(XMLTabbedPane,
						javax.swing.GroupLayout.DEFAULT_SIZE, 444,
						Short.MAX_VALUE));
		layout.setVerticalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addContainerGap()
								.addComponent(createXMLLabel)
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
								.addComponent(XMLTabbedPane,
										javax.swing.GroupLayout.DEFAULT_SIZE,
										345, Short.MAX_VALUE)
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.BASELINE)
												.addComponent(saveButton)
												.addComponent(clearButton))
								.addContainerGap()));

		pack();
	}// </editor-fold>

	// //////////
	private void saveButtonActionPerformed(ActionEvent arg0) {
		try {
			OutputStream fout;
			JFileChooser xmlDestinationFileChooser = new JFileChooser();
			xmlDestinationFileChooser.setAcceptAllFileFilterUsed(false);
			FileNameExtensionFilter filter = new FileNameExtensionFilter(
					"Extensible Markup Language (*.xml)", "xml");
			xmlDestinationFileChooser.setFileFilter(filter);
			if (xmlDestinationFileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
				if (xmlDestinationFileChooser.getSelectedFile()
						.getAbsolutePath().endsWith(".xml")) {
					fout = new FileOutputStream(xmlDestinationFileChooser
							.getSelectedFile().getAbsolutePath());
				} else {
					fout = new FileOutputStream(xmlDestinationFileChooser
							.getSelectedFile().getAbsolutePath() + ".xml");
				}

				// OutputStream fout = new FileOutputStream("generated.xml");
				OutputStream bout = new BufferedOutputStream(fout);
				OutputStreamWriter out = new OutputStreamWriter(bout);

				out.write("<?xml version=\"1.0\"?>\n");
				out.write("<syllabus>\n");
				out.write("\t<college>" + collegeTxtField.getText()
						+ "</college>\n");
				out.write("\t<department>" + departmentTxtField.getText()
						+ "</department>\n");
				out.write("\t<code>" + courseCodeTxtField.getText()
						+ "</code>\n");
				out.write("\t<faculty>" + facultyTxtField.getText()
						+ "</faculty>\n");
				out.write("\t<term>" + termTxtField.getText() + "</term>\n");
				out.write("\t<time>" + timeTxtField.getText() + "</time>\n");
				out.write("\t<room>" + roomTxtField.getText() + "</room>\n");

				out.write("\t<coursedesc>" + descriptionTxtArea.getText()
						+ "</coursedesc>\n");

				out.write("\t<los>\n");
				out.write("\t\t<learningdesc>"
						+ learningObjectivePreambleTxtArea.getText()
						+ "</learningdesc>\n");
				for (int i = 0; i < learningOutcomesList.getModel().getSize(); i++)
					out.write("\t\t<lo>"
							+ learningOutcomesList.getModel().getElementAt(i)
							+ "</lo>\n");
				out.write("\t</los>\n");
				
				out.write("\t<finaloutcomes>\n");
				out.write("\t\t<finaldesc>" /*+ finalOutcomePreambleTxtArea.getText()*/ + "</finaldesc>\n");
				/*
				for (int i = 0; i < outputsTable.getRowCount(); i++) {
					out.write("\t\t<finaloutcome>\n");
					out.write("\t\t\t\t<lo>"
							+ outputsTable.getModel().getValueAt(i, 0)
							+ "</lo>\n");
					out.write("\t\t\t\t<output>"
							+ outputsTable.getModel().getValueAt(i, 1)
							+ "</output>\n");
					out.write("\t\t\t\t<date>"
							+ outputsTable.getModel().getValueAt(i, 2)
							+ "</date>\n");
					out.write("\t\t</finaloutcome>\n");
				}
				*/
				out.write("\t</finaloutcomes>\n");
				
				out.write("\t<rubrics>\n");
				out.write("\t\t<rubricdesc>" /*+ rubricPreambleTxtArea.getText()*/ + "</rubricdesc>\n");
				/*
				for (int i = 0; i < rubricsTable.getRowCount(); i++) {
					out.write("\t\t<rubric>\n");
					out.write("\t\t\t\t<criteria>"
							+ rubricsTable.getModel().getValueAt(i, 0)
							+ "</criteria>\n");
					out.write("\t\t\t\t<exemplary>"
							+ rubricsTable.getModel().getValueAt(i, 1)
							+ "</exemplary>\n");
					out.write("\t\t\t\t<satisfactory>"
							+ rubricsTable.getModel().getValueAt(i, 2)
							+ "</satisfactory>\n");
					out.write("\t\t\t\t<developing>"
							+ rubricsTable.getModel().getValueAt(i, 3)
							+ "</developing>\n");
					out.write("\t\t\t\t<beginning>"
							+ rubricsTable.getModel().getValueAt(i, 4)
							+ "</beginning>\n");
					out.write("\t\t\t\t<rating>"
							+ rubricsTable.getModel().getValueAt(i, 5)
							+ "</rating>\n");
					out.write("\t\t</rubric>\n");
				}
				*/
				out.write("\t</rubrics>\n");
				
				out.write("\t<others listType=\""
						/*+ (String) othersComboBox.getSelectedItem()*/
						+ "\">\n");
				out.write("\t\t<otherdesc>" /*+ otherPreambleTxtArea.getText()*/ + "</otherdesc>\n");
				/*
				for (int i = 0; i < othersList.getModel().getSize(); i++)
					out.write("\t\t<other>"
							+ othersList.getModel().getElementAt(i)
							+ "</other>\n");
				*/
				out.write("\t</others>\n");
				
				out.write("\t<gradings>\n");
				out.write("\t\t<gradingdesc>" /*+ gradingPreambleTxtArea.getText()*/ + "</gradingdesc>\n");
				/*
				for (int i = 0; i < gradingsTable.getRowCount(); i++) {
					out.write("\t\t<grading>\n");
					out.write("\t\t\t\t<gradingrequirement>"
							+ gradingsTable.getModel().getValueAt(i, 0)
							+ "</gradingrequirement>\n");
					out.write("\t\t\t\t<gradingpercentage>"
							+ gradingsTable.getModel().getValueAt(i, 1)
							+ "</gradingpercentage>\n");
					out.write("\t\t</grading>\n");
				}
				for (int i = 0; i < gradingConversionsTable.getRowCount(); i++) {
					out.write("\t\t<gradingconversion>\n");
					out.write("\t\t\t\t<gradingrange>"
							+ gradingConversionsTable.getModel().getValueAt(i, 0)
							+ "</gradingrange>\n");
					out.write("\t\t\t\t<gradingpoint>"
							+gradingConversionsTable.getModel().getValueAt(i, 1)
							+ "</gradingpoint>\n");
					out.write("\t\t</gradingconversion>\n");
				}
				*/
				out.write("\t</gradings>\n");

				out.write("\t<learningplans>\n");
				out.write("\t\t<learningplandesc>" /*+ learningPlanPreambleTxtArea.getText()*/ + "</learningplandesc>\n");
				for (int i = 0; i < topicsTable.getRowCount(); i++) {
					out.write("\t\t<learningplan>\n");
					out.write("\t\t\t\t<lo>"
							+ topicsTable.getModel().getValueAt(i, 0)
							+ "</lo>\n");
					out.write("\t\t\t\t<topic>"
							+ topicsTable.getModel().getValueAt(i, 1)
							+ "</topic>\n");
					out.write("\t\t\t\t<week>"
							+ topicsTable.getModel().getValueAt(i, 2)
							+ "</week>\n");
					out.write("\t\t\t\t<activities>"
							+ topicsTable.getModel().getValueAt(i, 3)
							+ "</activities>\n");
					out.write("\t\t</learningplan>\n");
				}
				out.write("\t</learningplans>\n");
				
				out.write("\t<references>\n");
				out.write("\t\t<refdesc>" /*+ referencePreambleTxtArea.getText()*/ + "</refdesc>\n");
				for (int i = 0; i < referencesList.getModel().getSize(); i++)
					out.write("\t\t<ref>"
							+ referencesList.getModel().getElementAt(i)
							+ "</ref>\n");
				out.write("\t</references>\n");
				
				out.write("\t<online>\n");
				out.write("\t\t<onlinedesc>" /*+ onlinePreambleTxtArea.getText()*/ + "</onlinedesc>\n");
				/*
				for (int i = 0; i < resourcesList.getModel().getSize(); i++)
					out.write("\t\t<resource>"
							+ resourcesList.getModel().getElementAt(i)
							+ "</resource>\n");
				*/
				out.write("\t</online>\n");
				
				out.write("\t<policies listType=\""
						/*+ (String) policiesComboBox.getSelectedItem()*/
						+ "\">\n");
				out.write("\t\t<policydesc>" /*+ policyPreambleTxtArea.getText()*/ + "</policydesc>\n");
				/*
				for (int i = 0; i < policiesList.getModel().getSize(); i++)
					out.write("\t\t<policy>"
							+ policiesList.getModel().getElementAt(i)
							+ "</policy>\n");
				*/
				out.write("\t</policies>\n");

				out.write("</syllabus>");
				out.flush();
				out.close();
				System.out.println("XML Generated");
				this.setVisible(false);
			} // end of if
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static boolean isNumeric(String str) {
		return str.matches("\\d+(\\.\\d+)?"); // match a number with optional
												// '-' and decimal.
	}

	// /////////
	private void collegeTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void departmentTxtFieldActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void courseCodeTxtFieldActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void facultyTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void termTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void academicYearTxtFieldActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void timeTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void roomTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void requirementRemoveButtonActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void topicAddButtonActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void topicRemoveButtonActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void assessmentItemTxtFieldActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	/**
	 * @param args
	 *            the command line arguments
	 */
	/*
	 * public static void main(String args[]) {
	 * java.awt.EventQueue.invokeLater(new Runnable() { public void run() { }
	 * }); }
	 */

	// Variables declaration - do not modify
	private javax.swing.JComboBox RequirmentListTypeComboBox;
	private javax.swing.JTabbedPane XMLTabbedPane;
	private javax.swing.JButton assessmentAddButton;
	private javax.swing.JTextField assessmentItemTxtField;
	private javax.swing.JButton assessmentRemoveButton;
	private javax.swing.JTable assessmentTable;
	private javax.swing.JTextField assessmentValueTxtField;
	private javax.swing.JButton clearButton;
	private javax.swing.JTextField collegeTxtField;
	private javax.swing.JTextField departmentTxtField;
	private javax.swing.JTextField courseCodeTxtField;
	private javax.swing.JTextArea descriptionTxtArea;
	private javax.swing.JTextField facultyTxtField;
	private javax.swing.JButton textMaterialAddButton;
	private javax.swing.JButton referenceRemoveButton;
	private javax.swing.JButton referenceAddButton;
	private javax.swing.JButton textMaterialRemoveButton;
	private javax.swing.JComboBox textMaterialComboBox;
	private javax.swing.JLabel createXMLLabel;
	private javax.swing.JLabel topicLearningOutcomeLabel;
	private javax.swing.JLabel topicLabel;
	private javax.swing.JLabel topicWeekLabel;
	private javax.swing.JLabel topicLearningActivitiesLabel;
	private javax.swing.JLabel itemLabel;
	private javax.swing.JLabel valueLabel;
	private javax.swing.JLabel requirementListTypeLabel;
	private javax.swing.JLabel textMaterialListTypeLabel;
	private javax.swing.JLabel collegeLabel;
	private javax.swing.JLabel departmentLabel;
	private javax.swing.JLabel courseCodeLabel;
	private javax.swing.JLabel facultyLabel;
	private javax.swing.JLabel termLabel;
	private javax.swing.JLabel timeLabel;
	private javax.swing.JLabel roomLabel;
	private javax.swing.JList textMaterialsList;
	private javax.swing.JList referencesList;
	private javax.swing.JPanel detailsPanel;
	private javax.swing.JPanel learningOutcomesListPanel;
	private javax.swing.JPanel descriptionPanel;
	private javax.swing.JPanel learningOutcomesPanel;
	private javax.swing.JPanel learningPlanPanel;
	private javax.swing.JPanel requirementsPanel;
	private javax.swing.JPanel assessmentPanel;
	private javax.swing.JPanel textMaterialsPanel;
	private javax.swing.JPanel referencesPanel;
	private javax.swing.JPanel learningOutcomesPreamblePanel;
	private javax.swing.JScrollPane descriptionScrollPane;
	private javax.swing.JScrollPane learningObjectivePreambleScrollPane;
	private javax.swing.JScrollPane learningOutcomesListScrollPane;
	private javax.swing.JScrollPane topicsTableScrollPane;
	private javax.swing.JScrollPane requirementListScrollPane;
	private javax.swing.JScrollPane assessmentTableScrollPane;
	private javax.swing.JScrollPane textMaterialListScrollPane;
	private javax.swing.JScrollPane referenceScrollPane;
	private javax.swing.JTextField textMaterialTxtField;
	private javax.swing.JTextField referenceTxtField;
	private javax.swing.JButton learningOutcomeAddButton;
	private javax.swing.JButton learningOutcomeRemoveButton;
	private javax.swing.JTextField learningOutcomeTxtField;
	private javax.swing.JList learningOutcomesList;
	private javax.swing.JTextArea learningObjectivePreambleTxtArea;
	private javax.swing.JButton requirementAddButton;
	private javax.swing.JList requirementsList;
	private javax.swing.JButton requirementRemoveButton;
	private javax.swing.JTextField requirementTxtField;
	private javax.swing.JTextField roomTxtField;
	private javax.swing.JButton saveButton;
	private javax.swing.JTextField termTxtField;
	private javax.swing.JTextField timeTxtField;
	private javax.swing.JButton topicAddButton;
	private javax.swing.JTextField topicLearningOutcomeTxtField;
	private javax.swing.JTextField topicTxtField;
	private javax.swing.JButton topicRemoveButton;
	private javax.swing.JTextField topicWeekTxtField;
	private javax.swing.JTextField topicLearningActivitiesTxtField;
	private javax.swing.JTable topicsTable;
	private java.awt.Frame parent;
	private boolean modal;
	// End of variables declaration

	private DefaultListModel learningOutcomeListModel;
	private DefaultListModel requirementListModel;
	private DefaultListModel textMaterialListModel;
	private DefaultListModel referenceListModel;
	private DefaultTableModel assessmentTableModel;
	private DefaultTableModel topicTableModel;
}
